from django.shortcuts import render
# Create your views here.
import re
import time
import requests
import uuid
url_page="https://m.enterdesk.com/pic/"
ret=requests.get(url=url_page) #ret是HTML的响应对象
# print(ret.text) #ret.text是HTML的字符串形式
url_lst=re.findall(r"https://up.enterdesk.com/edpic_360_360.*?\.jpg",ret.text)
# 1.发送请求
for url in url_lst:
    res=requests.get(url=url)
    time.sleep(2)
    # 2.将相应数据转换为二进制流数据
    content = res.content
    # 3.将二进制流数据写入文件
    name = str(uuid.uuid1())+".jpg"
    with open(name,"wb")as f:
        print("正在下载%s" % name)
        f.write(content)